package top.eggcode.system.modules.user.store;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import top.eggcode.system.modules.user.model.rolePowerEntity;

import java.util.List;

/**
 * Title:
 * Description: TODO
 * Date: 2021/8/7 15:16
 *
 * @author JiaQi Ding
 * @version 1.0
 */
public interface RolePowerRepository extends JpaRepository<rolePowerEntity, String> {

    /**
     * 查找权限id列表
     *
     * @param roleId 角色id
     * @return
     */
    List<rolePowerEntity> findByRoleId(String roleId);

    /**
     * 删除权限
     *
     * @param roleId 角色
     */
    @Modifying
    @Query("delete from rolePowerEntity relation where relation.roleId = ?1")
    void batchDeleteByRole(String roleId);
}
